package com.elite;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;

import com.bill99.mgw.util.ParseUtil;

public class test {
	

public void test(String content,String POST_URL) throws IOException{
	   URL url = null ;
	   url = new URL(POST_URL);
		URLConnection uc = null;
	    OutputStreamWriter out = null;
	    BufferedReader rd = null;
	    uc = url.openConnection();
	    uc.setDoOutput(true); //....必须设置为'true'.
	    uc.setRequestProperty("Content-Type", "text/xml");   //记住这行不能少否则会出错 
	    out = new OutputStreamWriter(uc.getOutputStream(),"utf-8");
	    out.write(content);
	    out.flush();
	    out.close();
	    
	    rd = new BufferedReader(new InputStreamReader(uc.getInputStream(),"utf-8"));
	        String responseStr;
	        while ( (responseStr = rd.readLine()) != null) {
	            System.out.println("发送结果=" + responseStr);
	        }

	        rd.close();
	 
}
  public static void main(String[] args) throws IOException{
 try{
   String content="<?xml version='1.0' encoding='UTF-8' standalone='yes'?><MasMessage xmlns='http://www.99bill.com/mas_cnp_merchant_interface'><version>1.0</version><TxnMsgContent><txnType>PUR</txnType><interactiveStatus>TR2</interactiveStatus><amount>3</amount><merchantId>104110045110051</merchantId><terminalId>00000051</terminalId><entryTime>20110908104751</entryTime><externalRefNumber>20110908104751</externalRefNumber><transTime>20110908104757</transTime><refNumber>000000250444</refNumber><responseCode>00</responseCode><responseTextMessage>SSSSSSSS</responseTextMessage><cardOrg>CU</cardOrg><issuer>dddddddd</issuer><storableCardNo>5528010001</storableCardNo></TxnMsgContent></MasMessage>";
   String POST_URL = "http://localhost:8080/sanxing/EliteService";
   URL url = null ;
   url = new URL(POST_URL);
	URLConnection uc = null;
    OutputStreamWriter out = null;
    BufferedReader rd = null;
    uc = url.openConnection();
    uc.setDoOutput(true); //....必须设置为'true'.
    uc.setRequestProperty("Content-Type", "text/xml");   //记住这行不能少否则会出错 
    out = new OutputStreamWriter(uc.getOutputStream(),"utf-8");
    out.write(content);
    out.flush();
    out.close();
    
    rd = new BufferedReader(new InputStreamReader(uc.getInputStream(),"utf-8"));
        String responseStr;
        while ( (responseStr = rd.readLine()) != null) {
            System.out.println("发送结果=" + responseStr);
        }

        rd.close();
 }catch(Exception e){
	 e.printStackTrace();
 }
  }
}
